<template>
  <el-date-picker
    v-on="$listeners"
    v-bind="$attrs"
    v-model="value"
    type="daterange"
    range-separator="至"
    :start-placeholder="placeholder[0]"
    format="yyyy-MM-dd"
    value-format="yyyy-MM-dd"
    :end-placeholder="placeholder[1]">
  </el-date-picker>
</template>
<script>
  export default {
    name:"MyDateRange",
    props:{
      placeholder: {
        type: Array,
        default() {
          return ['开始时间','结束时间']
        }
      },
      startTime:{
        type:String,
        default:""
      },
      endTime:{
        type:String,
        default:""
      }
    },
    computed: {
      value: {
        get() {
          return [this.startTime, this.endTime]
        },
        set(v) {
          if (v && v.length > 1) {
            this.$emit("update:startTime",v[0])
            this.$emit("update:endTime",v[1])
          }else{
            this.$emit("update:startTime",undefined)
            this.$emit("update:endTime",undefined)
          }
        }
      },
    }
  }
</script>
